import { memo } from 'react';
import { RouteList } from './router';
import { BrowserRouter } from 'react-router-dom';
import { ConfigProvider } from 'antd';
import { ThemeProvider } from 'styled-components';
import { light, dark } from '@/assets/style/theme';
import { useMainStore } from './store/main';
import zhCN from 'antd/locale/zh_CN';
import dayjs from 'dayjs';
import 'dayjs/locale/zh-cn';
dayjs.locale('en');

const App = memo(() => {
	const theme = useMainStore((state) => state.theme);

	return (
		<ConfigProvider
			locale={zhCN}
			theme={{
				token: {
					colorPrimary: '#2e31d1'
				}
			}}
		>
			<BrowserRouter>
				<ThemeProvider theme={theme === 'dark' ? dark : light}>
					<RouteList />
				</ThemeProvider>
			</BrowserRouter>
		</ConfigProvider>
	);
});

export default App;
